package com.demo.text;

import java.io.*;
import java.text.NumberFormat;

public class io {
    public static void main(String[] args) throws IOException {
//        File file = new File("/Users/zhiqiang/t2");
//        File[] files = file.listFiles();
//        if (!file.exists()) {
//            file.mkdirs();
//        }
//        for (File file1:files) {
//            System.out.println(file1);
//            if ("c08b5287-909e-4461-9648-1e2981b8cea6.jpg".equals(file1.getName())) {
//                file1.delete();
//            }
//        }

        File file = new File("/Users/zhiqiang/t1/t2.txt");
        File file2 = new File("/Users/zhiqiang/t2/t2.txt");
        InputStream inputStream = new FileInputStream(file);
        // 输出流 append=true时，追加文件
        OutputStream outputStream = new FileOutputStream(file2, true);
        BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
        byte[] bytes = new byte[1024];
        int read = bufferedInputStream.read(bytes);
        while (read != -1) {
            bufferedOutputStream.write(bytes, 0, read);
            read = bufferedInputStream.read(bytes);
        }
        bufferedOutputStream.close();
        bufferedInputStream.close();
        outputStream.close();
        inputStream.close();
    }
}
